<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.lmpop.trade.ti_goods.Ti_goodsInfo" %>
<%@page import="com.lmpop.trade.ti_customer.Ti_customerInfo" %>
<%@page import="com.lmpop.trade.tb_commpara.Tb_commparaInfo" %>
<%@page import="com.lmpop.trade.ts_category.*" %>
<%@page import="com.lmpop.trade.ts_categoryattr.*" %>

<%
 
   request.setCharacterEncoding("utf-8");
   
   String goods_id="",position="";
	
    if(request.getParameter("goods_id") != null){
		   goods_id = request.getParameter("goods_id").trim();
	}
	 if(request.getParameter("position") != null){
		   position = request.getParameter("position").trim();
	}
  
   Ti_goodsInfo  ti_goodsInfo =  new Ti_goodsInfo();
   
   //Ti_customerInfo ti_customerInfo = new Ti_customerInfo();
   //Tb_commparaInfo tb_commparaInfo =new Tb_commparaInfo();
   
   Ts_categoryattrInfo ts_categoryattrInfo = new Ts_categoryattrInfo();
  
  	List gdlist = ti_goodsInfo.getListByPk(goods_id);
   
    //out.print("--------->"+gdlist);   
   %>     
<html>

    <head>
        <meta http-equiv="x-ua-compatible" content="ie=7" />
        <title>more college</title>
         <link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
        </head>

    <body>
    
			<div style="width:100%;">
		   <table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
				
				<tr>
			    <td>
        	<%
        	 if(gdlist!=null && gdlist.size()>0){
        	   Hashtable gdMap =(Hashtable)gdlist.get(0);
             String class_attr="";
             if(gdMap.get("class_attr")!=null)
             {
                class_attr = gdMap.get("class_attr").toString();             
             }
             String catAttr[] = class_attr.split("\\|");
             List attList = new ArrayList();
					   if(!catAttr[catAttr.length-1].equals(""))
					   {
					    	attList = ts_categoryattrInfo.getListByClassId(catAttr[catAttr.length-1]);
					   }  
					   
					   
					   List attrValueList = new ArrayList();
						 int attrsize = 0,valuesize = 0;
    			   if( attList != null && attList.size() > 0 ){
						 attrsize = attList.size();
						 Hashtable attrmap = new Hashtable();
					 	 for( int i = 0; i < attrsize; i++ )
						 {
						 	 attrmap = ( Hashtable )attList.get(i);
							 String attr_id = "",attr_name = "",default_tag ="", con_type="",attrStr = "",isfill="";
							 if( attrmap.get("attr_id") != null )
							 {
							 	 attr_id = attrmap.get( "attr_id" ).toString();
							 }
							 if( attrmap.get("attr_name") != null )
							 {
							 	 attr_name = attrmap.get( "attr_name" ).toString();
							 }
							 if( attrmap.get("default_tag") != null )  // if fill in or not									 
							 {
							 	 default_tag = attrmap.get("default_tag" ).toString();
							 }
							 if( attrmap.get("con_type") != null )
							 {
							 	 con_type = attrmap.get("con_type").toString();
							 }
							 if( default_tag.equals( "0" ))
							 {
							 	 isfill = " <span style='color:red;'>*</span>";
							 }
									
									 
						%>
						
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
			        <tr>
			          <td width="18%" height="35" align="right" style="background:#F9F9F9;">
			          	 &nbsp;<%=attr_name%><%=isfill%>
			          </td>
			          
			          <td width="48%" style="background:#F9F9F9;">
			          	
			          								  
								  <input type="hidden" name="attr_id<%=i%>" id="attr_id<%=i%>" value="<%=attr_id%>" /> 
								  <input type="hidden" name="attr_name<%=i%>" id="attr_name<%=i%>" value="<%=attr_name%>" />
								  <input type="hidden" name="con_type<%=i%>" id="con_type<%=i%>" value="<%=con_type%>" />
								  <input type="hidden" name="default_tag<%=i%>" id="default_tag<%=i%>" value="<%=default_tag%>" />
			          	<%
			          			String attrValue = "";
											
								  if(con_type.equals("0"))
								  {
										 
										 attrValue = ts_categoryattrInfo.getSelectItems(attr_id,"");
																	
							%>	
									   <select class="input" name="attr_value<%=i%>" id="attr_value<%=i%>"  style="height:20px;">
									   <option value="">请选择</option>
											 <%=attrValue%>
									   </select>
							<%			
									}
										
									if( con_type.equals( "1") )
									{
										 
							 %>
										<input class="input" maxlength="30" type="text" name="attr_value<%=i%>" id="attr_value<%=i%>"  value="" size="20" maxlength="100" />
							<%			
									}
									if( con_type.equals( "2") ){
											attrValueList = ts_categoryattrInfo.getListByPk( attr_id );
											if( attrValueList != null && attrValueList.size() > 0 ) 
											{
		                           
											Hashtable valuemap = (Hashtable)attrValueList.get(0);
											String default_value="";                           
											if( valuemap.get("default_value") != null )
											{
												default_value = valuemap.get("default_value").toString();
											}
															  
	                    String attrValues[] = default_value.split("\\|");												  
										  valuesize = attrValues.length;
										  for( int k = 0; k < valuesize; k++ ) 
										  {
									     %>
												    <input class="input" type="radio" name="attr_value<%=i%>" id="attr_value<%=i%>_<%=k%>" value="<%=attrValues[k]%>" /><%=attrValues[k]%>	
												    									
											 <%	   
											      }
											 %>  	
											  
											 <input type="hidden" name="valuesize<%=i%>" id="valuesize<%=i%>" value="<%=valuesize%>" /> 

											  <%
											}
										}
									%>		
			            <span class="STYLE5"></span>
			          </td>
			         	</tr>
			      </table>
			      <%		}
							 }
						%>
						
					<input type="hidden" name="attrsize" id="attrsize" value="<%=attrsize%>" />
        	
        	<%
        	}
        	%>        	        	
        
        </td>        
        
        </tr>				
				
			</table> 
			</div>
			<br/>
			
			
			<div style="text-align:center;">
			<input type="button" class="buttoncss" value="确定" onclick="setGoodsAttr('<%=position%>');">
      </div> 
    </body>
</html>
